<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>C++ 代码实例：多项式除法简单计算工具 | 夜悊的技术小宅</title><meta name="author" content="夜悊"><meta name="copyright" content="夜悊"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="前言C++ 代码实例：多项式除法简单计算工具。  代码仓库 yezhening&#x2F;Programming-examples: 编程实例 (github.com) Programming-examples: 编程实例 (gitee.com)   代码说明 由于代码篇幅较多，在博客中直接粘贴并呈现会显得冗长，因此未在博客中放置完整代码，只展示核心片段代码。请前往”代码仓库”查看或获取相关代码">
<meta property="og:type" content="article">
<meta property="og:title" content="C++ 代码实例：多项式除法简单计算工具">
<meta property="og:url" content="http://example.com/2023/11/05/C++%20%E4%BB%A3%E7%A0%81%E5%AE%9E%E4%BE%8B%EF%BC%9A%E5%A4%9A%E9%A1%B9%E5%BC%8F%E9%99%A4%E6%B3%95%E7%AE%80%E5%8D%95%E8%AE%A1%E7%AE%97%E5%B7%A5%E5%85%B7/index.html">
<meta property="og:site_name" content="夜悊的技术小宅">
<meta property="og:description" content="前言C++ 代码实例：多项式除法简单计算工具。  代码仓库 yezhening&#x2F;Programming-examples: 编程实例 (github.com) Programming-examples: 编程实例 (gitee.com)   代码说明 由于代码篇幅较多，在博客中直接粘贴并呈现会显得冗长，因此未在博客中放置完整代码，只展示核心片段代码。请前往”代码仓库”查看或获取相关代码">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/img/cover17.png">
<meta property="article:published_time" content="2023-11-05T04:14:19.000Z">
<meta property="article:modified_time" content="2024-02-28T03:12:15.036Z">
<meta property="article:author" content="夜悊">
<meta property="article:tag" content="C++">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/img/cover17.png"><link rel="shortcut icon" href="/img/favicon2.png"><link rel="canonical" href="http://example.com/2023/11/05/C++%20%E4%BB%A3%E7%A0%81%E5%AE%9E%E4%BE%8B%EF%BC%9A%E5%A4%9A%E9%A1%B9%E5%BC%8F%E9%99%A4%E6%B3%95%E7%AE%80%E5%8D%95%E8%AE%A1%E7%AE%97%E5%B7%A5%E5%85%B7/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css?v=4.13.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 夜悊","link":"链接: ","source":"来源: 夜悊的技术小宅","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid@4.11.1/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'C++ 代码实例：多项式除法简单计算工具',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-02-28 11:12:15'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/my_css.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">92</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">15</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-bookmark"></i><span> 笔记目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-blog"></i><span> 其他博客</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/m0_62083249"><i class="fa-fw fa fa-link"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/ye-zhe-ning"><i class="fa-fw fa fa-link"></i><span> 知乎</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-sitemap"></i><span> 代码仓库</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gitee.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Gitee</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://github.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Github</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about_me/"><i class="fa-fw fas fa-user"></i><span> 关于我</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/img/cover17.png')"><nav id="nav"><span id="blog-info"><a href="/" title="夜悊的技术小宅"><span class="site-name">夜悊的技术小宅</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-bookmark"></i><span> 笔记目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-blog"></i><span> 其他博客</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/m0_62083249"><i class="fa-fw fa fa-link"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/ye-zhe-ning"><i class="fa-fw fa fa-link"></i><span> 知乎</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fa fa-sitemap"></i><span> 代码仓库</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gitee.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Gitee</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://github.com/yezhening"><i class="fa-fw fa fa-link"></i><span> Github</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about_me/"><i class="fa-fw fas fa-user"></i><span> 关于我</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">C++ 代码实例：多项式除法简单计算工具</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-11-05T04:14:19.000Z" title="发表于 2023-11-05 12:14:19">2023-11-05</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-02-28T03:12:15.036Z" title="更新于 2024-02-28 11:12:15">2024-02-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/C/">C++</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="C++ 代码实例：多项式除法简单计算工具"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>C++ 代码实例：多项式除法简单计算工具。</p>
<hr>
<h1 id="代码仓库"><a href="#代码仓库" class="headerlink" title="代码仓库"></a>代码仓库</h1><ul>
<li><a target="_blank" rel="noopener" href="https://github.com/yezhening/Programming-examples">yezhening&#x2F;Programming-examples: 编程实例 (github.com)</a></li>
<li><a target="_blank" rel="noopener" href="https://gitee.com/yezhening/Programming-examples">Programming-examples: 编程实例 (gitee.com)</a></li>
</ul>
<hr>
<h1 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h1><h2 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h2><ul>
<li>由于代码篇幅较多，在博客中直接粘贴并呈现会显得冗长，因此未在博客中放置<strong>完整</strong>代码，只展示<strong>核心片段</strong>代码。请前往”代码仓库”查看或获取相关代码</li>
<li>简单地计算多项式除法</li>
<li><strong>注释有详细的步骤解析</strong></li>
<li>好用的多项式除法在线计算网址：<a target="_blank" rel="noopener" href="https://zh.planetcalc.com/7717/">在线计算器: 多项式除法 (planetcalc.com)</a></li>
<li>多项式除法，被除数和除数写在程序中：main.exe、main.cpp、polynomial.cpp、polynomial.h</li>
<li>多项式除法，在终端输入被除数和除数：main1.exe、main1.cpp、polynomial.cpp、polynomial.h</li>
</ul>
<blockquote>
<p>注：一个晚上一个早上完成，应该大部分结果对，若出现小部分结果错误懒得管了，逻辑差不多那样</p>
</blockquote>
<hr>
<h2 id="核心片段"><a href="#核心片段" class="headerlink" title="核心片段"></a>核心片段</h2><p>polynomial.h</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifndef</span> POLYNOMIAL_H</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> POLYNOMIAL_H</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> std::ostream;</span><br><span class="line"><span class="keyword">using</span> std::vector;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 多项式类</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Polynomial</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="function"><span class="keyword">explicit</span> <span class="title">Polynomial</span><span class="params">(<span class="type">const</span> vector&lt;<span class="type">int</span>&gt; &amp;p)</span> : poly_vec(p) &#123;</span>&#125; <span class="comment">// 私有成员只能在类的成员函数内部被初始化</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 重载运算符 “&lt;&lt;” 输出多项式</span></span><br><span class="line">    <span class="comment">// friend：类外会用该运算符访问类的成员，不写报错：too many parameters for this operator function</span></span><br><span class="line">    <span class="comment">// 返回输出流对象引用，可以链式操作</span></span><br><span class="line">    <span class="keyword">friend</span> ostream &amp;<span class="keyword">operator</span>&lt;&lt;(ostream &amp;output, <span class="type">const</span> Polynomial &amp;obj);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 重载运算符 “/” 进行多项式除法</span></span><br><span class="line">    <span class="comment">// 返回值：商</span></span><br><span class="line">    <span class="comment">// 参数：除数</span></span><br><span class="line">    Polynomial <span class="keyword">operator</span>/(<span class="type">const</span> Polynomial &amp;divisor) <span class="type">const</span>; <span class="comment">// const表示不会改变调用该方法的被除数</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 重载运算符 “%” 进行多项式除法求余</span></span><br><span class="line">    <span class="comment">// 返回值：余数</span></span><br><span class="line">    <span class="comment">// 参数：除数</span></span><br><span class="line">    <span class="comment">// 照搬除法逻辑，只改动最后return的返回值，最后的余数就是最后更新的被除数</span></span><br><span class="line">    Polynomial <span class="keyword">operator</span>%(<span class="type">const</span> Polynomial &amp;divisor) <span class="type">const</span>; <span class="comment">// const表示不会改变调用该方法的被除数</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="type">const</span> vector&lt;<span class="type">int</span>&gt; poly_vec; <span class="comment">// 多项式的向量表示</span></span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span> <span class="comment">// POLYNOMIAL_H</span></span></span><br></pre></td></tr></table></figure>

<p>polynomial.cpp</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 重载运算符 “&lt;&lt;” 输出多项式</span></span><br><span class="line"><span class="comment">// 不需要friend、类作用域声名，因为是类外的运算符</span></span><br><span class="line">ostream &amp;<span class="keyword">operator</span>&lt;&lt;(ostream &amp;output, <span class="type">const</span> Polynomial &amp;obj)</span><br><span class="line">&#123;</span><br><span class="line">    UINT terminal_code_page = <span class="built_in">GetConsoleOutputCP</span>(); <span class="comment">// 获取当前终端的输出代码页</span></span><br><span class="line">    <span class="keyword">if</span> (terminal_code_page != <span class="number">65001</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">system</span>(<span class="string">&quot;chcp 65001&quot;</span>); <span class="comment">// 终端切换使用utf8字符集显示，以可以显示utf8的上标</span></span><br><span class="line">        <span class="comment">// 注意：会切换终端页，需要重新运行程序</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="comment">// 65001</span></span><br><span class="line">    &#123;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> i = obj.poly_vec.<span class="built_in">size</span>() - <span class="number">1</span>; i &gt;= <span class="number">0</span>; --i) <span class="comment">// 从高位到低位    i既表示索引也表示次数</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">// 1. 系数的符号</span></span><br><span class="line">        <span class="comment">// 正数显示+，负数不显示-，系数负数已有-</span></span><br><span class="line">        <span class="keyword">if</span> (obj.poly_vec.<span class="built_in">at</span>(i) &gt;= <span class="number">0</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            cout &lt;&lt; <span class="string">&quot;+&quot;</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="comment">// obj.poly.at(i) &lt; 0</span></span><br><span class="line">        &#123;</span><br><span class="line">            <span class="comment">// cout &lt;&lt; &quot; - &quot;;</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 2. 系数</span></span><br><span class="line">        cout &lt;&lt; obj.poly_vec.<span class="built_in">at</span>(i);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 3. 形式参数</span></span><br><span class="line">        cout &lt;&lt; <span class="string">&quot;x&quot;</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 4. 次数</span></span><br><span class="line">        <span class="comment">// 上标号的utf8编码</span></span><br><span class="line">        <span class="comment">// 如：0上标号⁰的utf8编码在索引0为\u2070，1上标号¹的utf8编码在索引1为\u00B9，以此类推</span></span><br><span class="line">        vector&lt;string&gt; superscript_utf8&#123;<span class="string">&quot;\u2070&quot;</span>, <span class="string">&quot;\u00B9&quot;</span>, <span class="string">&quot;\u00B2&quot;</span>, <span class="string">&quot;\u00B3&quot;</span>, <span class="string">&quot;\u2074&quot;</span>, <span class="string">&quot;\u2075&quot;</span>, <span class="string">&quot;\u2076&quot;</span>, <span class="string">&quot;\u2077&quot;</span>, <span class="string">&quot;\u2078&quot;</span>, <span class="string">&quot;\u2079&quot;</span>&#125;;</span><br><span class="line"></span><br><span class="line">        cout &lt;&lt; superscript_utf<span class="number">8.</span><span class="built_in">at</span>(i);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> output;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 重载运算符 “/” 进行多项式除法</span></span><br><span class="line"><span class="comment">// 返回值：商</span></span><br><span class="line"><span class="comment">// 参数：除数</span></span><br><span class="line">Polynomial Polynomial::<span class="keyword">operator</span>/(<span class="type">const</span> Polynomial &amp;divisor) <span class="type">const</span> <span class="comment">// const表示不会改变调用该方法的被除数</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">// 1. 准备被除数、除数和商</span></span><br><span class="line">    <span class="comment">// 解封装，获取被除数和除数向量</span></span><br><span class="line">    <span class="comment">// 1.1 方便操作</span></span><br><span class="line">    <span class="comment">// 1.2 不再是const，可以修改再封装出去</span></span><br><span class="line">    <span class="function">vector&lt;<span class="type">int</span>&gt; <span class="title">dividend_vec</span><span class="params">(<span class="keyword">this</span>-&gt;poly_vec)</span></span>;  <span class="comment">// 被除数</span></span><br><span class="line">    <span class="function">vector&lt;<span class="type">int</span>&gt; <span class="title">divisor_vec</span><span class="params">(divisor.poly_vec)</span></span>; <span class="comment">// 除数</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 商初始的次数是被除数最高项次数 - 除数最高项次数 + 1</span></span><br><span class="line">    <span class="comment">// 如：</span></span><br><span class="line">    <span class="comment">// 4x³ + 3x² + 2x + 1，的个数是4，最高项次数次数是 4 - 1 = 3</span></span><br><span class="line">    <span class="comment">// x² + 2x + 1的个数是3，最高项次数次数是 3 - 1 = 2</span></span><br><span class="line">    <span class="comment">// 最高项相除，4x³ / x² = 4x，商的最高项次数是 3 - 2 = 1</span></span><br><span class="line">    <span class="comment">// 因为索引从0开始，所以需要+1，商系数的个数是1 + 1 = 2，初始化为0</span></span><br><span class="line">    <span class="function">vector&lt;<span class="type">int</span>&gt; <span class="title">quotient_vec</span><span class="params">((dividend_vec.size() - <span class="number">1</span>) - (divisor_vec.size() - <span class="number">1</span>) + <span class="number">1</span>, <span class="number">0</span>)</span></span>; <span class="comment">// 商</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 2. 除法运算</span></span><br><span class="line">    <span class="comment">// 2.1 如果被除数最高项次数 &lt; 除数最高项次数，即 dividend_vec.size() - 1 &lt; divisor_vec.size() - 1，商返回0</span></span><br><span class="line">    <span class="comment">// 如：4x³ + 3x² + 2x + 1 / x⁵ + 2x + 3，被除数最高项 4x³ 次数4 &lt; 除数最高项 x⁵ 次数5，无法除，返回0（只有1个元素，索引0值0）</span></span><br><span class="line">    <span class="keyword">if</span> ((dividend_vec.<span class="built_in">size</span>() - <span class="number">1</span>) &lt; (divisor_vec.<span class="built_in">size</span>() - <span class="number">1</span>))</span><br><span class="line">    &#123;</span><br><span class="line">        quotient_vec.<span class="built_in">resize</span>(<span class="number">1</span>, <span class="number">0</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// ...</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 重载运算符 “%” 进行多项式除法求余</span></span><br><span class="line"><span class="comment">// 返回值：余数</span></span><br><span class="line"><span class="comment">// 参数：除数</span></span><br><span class="line"><span class="comment">// 照搬除法逻辑，只改动最后return的返回值，最后的余数就是最后更新的被除数</span></span><br><span class="line">Polynomial Polynomial::<span class="keyword">operator</span>%(<span class="type">const</span> Polynomial &amp;divisor) <span class="type">const</span> <span class="comment">// const表示不会改变调用该方法的被除数</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">// ...</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>main.cpp</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;polynomial.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> std::cout;</span><br><span class="line"><span class="keyword">using</span> std::endl;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">// int 型向量表示多项式，x作为形式参数无具体意义只有方便理解的展示意义，索引表示次数，值表示系数</span></span><br><span class="line">    <span class="comment">// 如 &#123;1, 2&#125;，索引0值1表示1x⁰，索引1值2表示2x¹，所以多项式是：2x¹ + 1x⁰ = 2x + 1</span></span><br><span class="line">    <span class="type">const</span> vector&lt;<span class="type">int</span>&gt; dividend_vec&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>&#125;; <span class="comment">// 被除数，4x³ + 3x² + 2x + 1</span></span><br><span class="line">    <span class="type">const</span> vector&lt;<span class="type">int</span>&gt; divisor_vec&#123;<span class="number">3</span>,<span class="number">2</span>,<span class="number">1</span>&#125;;        <span class="comment">// 除数，x² + 2x + 3</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 多项式类表示多项式，进一步封装</span></span><br><span class="line">    <span class="function"><span class="type">const</span> Polynomial <span class="title">dividend</span><span class="params">(dividend_vec)</span></span>;</span><br><span class="line">    <span class="function"><span class="type">const</span> Polynomial <span class="title">divisor</span><span class="params">(divisor_vec)</span></span>;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;被除数: &quot;</span> &lt;&lt; dividend &lt;&lt; endl;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;除数: &quot;</span> &lt;&lt; divisor &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 多项式除法求商</span></span><br><span class="line">    Polynomial quotient = dividend / divisor;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;商: &quot;</span> &lt;&lt; quotient &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 多项式除法求余数</span></span><br><span class="line">    Polynomial remainder = dividend % divisor;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;余数: &quot;</span> &lt;&lt; remainder &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>main1.cpp</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#include &lt;sstream&gt; // istringstream</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#include &quot;polynomial.h&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> std::cin;</span><br><span class="line"><span class="keyword">using</span> std::cout;</span><br><span class="line"><span class="keyword">using</span> std::endl;</span><br><span class="line"><span class="keyword">using</span> std::getline;</span><br><span class="line"><span class="keyword">using</span> std::istringstream;</span><br><span class="line"><span class="keyword">using</span> std::string;</span><br><span class="line"></span><br><span class="line">int main()</span><br><span class="line">&#123;</span><br><span class="line">    // 终端输入被除数和除数</span><br><span class="line">    // int 型向量表示多项式，x作为形式参数无具体意义只有方便理解的展示意义，索引表示次数，值表示系数</span><br><span class="line">    // 如 &#123;<span class="number">1</span>, <span class="number">2</span>&#125;，索引<span class="number">0</span>值<span class="number">1</span>表示<span class="number">1</span>x⁰，索引<span class="number">1</span>值<span class="number">2</span>表示<span class="number">2</span>x¹，所以多项式是：<span class="number">2</span>x¹ + <span class="number">1</span>x⁰ = <span class="number">2</span>x + <span class="number">1</span></span><br><span class="line">    // <span class="number">1</span>. 被除数</span><br><span class="line">    vector&lt;int&gt; dividend_vec(<span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;被除数系数，从高到低位输入，空格分隔，回车结束: &quot;</span> &lt;&lt; endl;</span><br><span class="line">    string input(<span class="string">&quot;&quot;</span>);</span><br><span class="line">    getline(cin, input); // 从终端获取一行输入</span><br><span class="line"></span><br><span class="line">    istringstream iss(input); // 字符串 -&gt; 输入流对象</span><br><span class="line">    int num(<span class="number">0</span>);</span><br><span class="line">    <span class="keyword">while</span> (iss &gt;&gt; num) // 输入流对象 -&gt; 数字</span><br><span class="line">    &#123;</span><br><span class="line">        dividend_vec.insert(dividend_vec.begin(), num); // 从后往前插入</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    // <span class="number">2</span>. 除数</span><br><span class="line">    vector&lt;int&gt; divisor_vec(<span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;除数系数，从高到低位输入，空格分隔，回车结束: &quot;</span> &lt;&lt; endl;</span><br><span class="line">    input = <span class="string">&quot;&quot;</span>;</span><br><span class="line">    getline(cin, input);</span><br><span class="line"></span><br><span class="line">    iss.clear(); // 清楚流状态，否则获取不到数字</span><br><span class="line">    iss.str(input);</span><br><span class="line">    num = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (iss &gt;&gt; num)</span><br><span class="line">    &#123;</span><br><span class="line">        divisor_vec.insert(divisor_vec.begin(), num);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    // 多项式类表示多项式，进一步封装</span><br><span class="line">    const Polynomial dividend(dividend_vec);</span><br><span class="line">    const Polynomial divisor(divisor_vec);</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;被除数: &quot;</span> &lt;&lt; dividend &lt;&lt; endl;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;除数: &quot;</span> &lt;&lt; divisor &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    // 多项式除法求商</span><br><span class="line">    Polynomial quotient = dividend / divisor;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;商: &quot;</span> &lt;&lt; quotient &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    // 多项式除法求余数</span><br><span class="line">    Polynomial remainder = dividend % divisor;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;余数: &quot;</span> &lt;&lt; remainder &lt;&lt; endl;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>Makefile</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">.PHONY : all</span><br><span class="line">all : main.exe main1.exe</span><br><span class="line"></span><br><span class="line">main.exe : main.cpp polynomial.cpp</span><br><span class="line">	g++ <span class="literal">-o</span> <span class="variable">$</span><span class="selector-tag">@</span> <span class="variable">$</span>^</span><br><span class="line"></span><br><span class="line">main1.exe : main1.cpp polynomial.cpp</span><br><span class="line">	g++ <span class="literal">-o</span> <span class="variable">$</span><span class="selector-tag">@</span> <span class="variable">$</span>^</span><br><span class="line"></span><br><span class="line">.PHONY : clean</span><br><span class="line">clean :</span><br><span class="line">	<span class="built_in">del</span> *.exe</span><br></pre></td></tr></table></figure>

<hr>
<h1 id="结果"><a href="#结果" class="headerlink" title="结果"></a>结果</h1><p><img src= "" data-lazy-src="/../img/polynomial_division/one.png" alt="在这里插入图片描述"></p>
<hr>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>C++ 代码实例：多项式除法简单计算工具。</p>
<hr>
<h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><ul>
<li>无具体的参考资料</li>
</ul>
<hr>
<h1 id="作者的话"><a href="#作者的话" class="headerlink" title="作者的话"></a>作者的话</h1><ul>
<li><strong>感谢参考资料的作者&#x2F;博主</strong></li>
<li>作者：夜悊</li>
<li>版权所有，转载请注明出处，谢谢~</li>
<li><strong>如果文章对你有帮助，请点个赞或加个粉丝吧，你的支持就是作者的动力~</strong></li>
<li>文章在描述时有疑惑的地方，请留言，定会一一耐心讨论、解答</li>
<li>文章在认识上有错误的地方, 敬请批评指正</li>
<li>望读者们都能有所收获</li>
</ul>
<hr>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="http://example.com">夜悊</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/11/05/C++%20%E4%BB%A3%E7%A0%81%E5%AE%9E%E4%BE%8B%EF%BC%9A%E5%A4%9A%E9%A1%B9%E5%BC%8F%E9%99%A4%E6%B3%95%E7%AE%80%E5%8D%95%E8%AE%A1%E7%AE%97%E5%B7%A5%E5%85%B7/">http://example.com/2023/11/05/C++ 代码实例：多项式除法简单计算工具/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">夜悊的技术小宅</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/C/">C++</a></div><div class="post_share"><div class="social-share" data-image="/img/cover17.png" data-sites="qq,wechat,weibo"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/11/03/C++%20STL%20%E5%85%AD%E7%BB%84%E4%BB%B6%E4%BB%8B%E7%BB%8D/" title="C++ STL 六组件介绍"><img class="cover" src= "" data-lazy-src="/img/cover12.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">C++ STL 六组件介绍</div></div></a></div><div class="next-post pull-right"><a href="/2023/11/06/C++%20%E4%BB%A3%E7%A0%81%E5%AE%9E%E4%BE%8B%EF%BC%9A%E5%B9%B6%E6%9F%A5%E9%9B%86%E7%AE%80%E5%8D%95%E5%88%9B%E5%BB%BA%E5%B7%A5%E5%85%B7/" title="C++ 代码实例：并查集简单创建工具"><img class="cover" src= "" data-lazy-src="/img/cover15.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">C++ 代码实例：并查集简单创建工具</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2023/11/08/C%20%E5%92%8C%20C++%20%E5%8F%AF%E5%8F%98%E5%8F%82%E6%95%B0%E4%BB%8B%E7%BB%8D/" title="C 和 C++ 可变参数介绍"><img class="cover" src= "" data-lazy-src="/img/cover6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-08</div><div class="title">C 和 C++ 可变参数介绍</div></div></a></div><div><a href="/2023/11/03/C++%20STL%20%E5%85%AD%E7%BB%84%E4%BB%B6%E4%BB%8B%E7%BB%8D/" title="C++ STL 六组件介绍"><img class="cover" src= "" data-lazy-src="/img/cover12.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-03</div><div class="title">C++ STL 六组件介绍</div></div></a></div><div><a href="/2023/10/01/C++%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E6%8E%92%E5%88%97%E6%95%B0%E7%AE%80%E5%8D%95%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7/" title="C++代码示例：排列数简单生成工具"><img class="cover" src= "" data-lazy-src="/img/cover15.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-10-01</div><div class="title">C++代码示例：排列数简单生成工具</div></div></a></div><div><a href="/2023/09/28/C++%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E7%BB%84%E5%90%88%E6%95%B0%E7%AE%80%E5%8D%95%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7/" title="C++代码示例：组合数简单生成工具"><img class="cover" src= "" data-lazy-src="/img/cover6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-09-28</div><div class="title">C++代码示例：组合数简单生成工具</div></div></a></div><div><a href="/2023/11/06/C++%20%E4%BB%A3%E7%A0%81%E5%AE%9E%E4%BE%8B%EF%BC%9A%E5%B9%B6%E6%9F%A5%E9%9B%86%E7%AE%80%E5%8D%95%E5%88%9B%E5%BB%BA%E5%B7%A5%E5%85%B7/" title="C++ 代码实例：并查集简单创建工具"><img class="cover" src= "" data-lazy-src="/img/cover15.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-06</div><div class="title">C++ 代码实例：并查集简单创建工具</div></div></a></div><div><a href="/2023/10/02/C++%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%EF%BC%9A%E8%BF%9B%E5%88%B6%E6%95%B0%E7%AE%80%E5%8D%95%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7/" title="C++代码示例：进制数简单生成工具"><img class="cover" src= "" data-lazy-src="/img/cover17.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-10-02</div><div class="title">C++代码示例：进制数简单生成工具</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E8%A8%80"><span class="toc-number">1.</span> <span class="toc-text">前言</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E4%BB%93%E5%BA%93"><span class="toc-number">2.</span> <span class="toc-text">代码仓库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81"><span class="toc-number">3.</span> <span class="toc-text">代码</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AF%B4%E6%98%8E"><span class="toc-number">3.1.</span> <span class="toc-text">说明</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%A0%B8%E5%BF%83%E7%89%87%E6%AE%B5"><span class="toc-number">3.2.</span> <span class="toc-text">核心片段</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BB%93%E6%9E%9C"><span class="toc-number">4.</span> <span class="toc-text">结果</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-number">5.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="toc-number">6.</span> <span class="toc-text">参考资料</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%9C%E8%80%85%E7%9A%84%E8%AF%9D"><span class="toc-number">7.</span> <span class="toc-text">作者的话</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('/img/cover17.png')"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2025 By 夜悊</div><div class="footer_custom_text"><a target="_blank" href="https://beian.miit.gov.cn/" >琼ICP备2023001225号-1</a><br><img src= "" data-lazy-src="/img/beian.png"/>&nbsp<a target="_blank" href="https://www.beian.gov.cn/portal/registerSystemInfo?recordcode=46010802001221" >琼公网安备 46010802001221号</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换">繁</button><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js?v=4.13.0"></script><script src="/js/main.js?v=4.13.0"></script><script src="/js/tw_cn.js?v=4.13.0"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.8/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js?v=4.13.0"></script></div></div></body></html>